import { ResPage, Goods } from "@/api/interface/index";
import http from "@/api";

/**
 * @name 商品管理模块
 */
// 获取商品列表
export const getGoodList = (params: Goods.ReqGoodParams) => {
  return http.post<ResPage<Goods.ResGoodList>>(`/goods/list`, params);
};

// 获取树形商品列表
export const getGoodsList = (params: Goods.ReqGoodParams) => {
  return http.post<ResPage<Goods.ResGoodList>>(`/goods/list`, params);
};

// 新增商品
export const addGood = (params: { id: string }) => {
  return http.post(`/goods`, params);
};

// 批量添加商品
export const BatchAddGood = (params: FormData) => {
  return http.post(`/Good/import`, params);
};

// 编辑商品
export const editGood = (params: { id: string }) => {
  return http.put(`/goods`, params);
};

// 删除商品
export const deleteGood = (params: { id: string }) => {
  return http.delete(`/goods`, params);
};

// 切换商品状态
export const changeGoodStatus = (params: { id: string; status: number }) => {
  return http.post(`/Good/change`, params);
};

// 重置商品密码
export const resetGoodPassWord = (params: { id: string }) => {
  return http.post(`/Good/rest_password`, params);
};

// 导出商品数据
export const exportGoodInfo = (params: Goods.ReqGoodParams) => {
  return http.download(`/Good/export`, params);
};

// 获取商品状态字典
export const getGoodStatus = () => {
  return http.get<Goods.ResStatus[]>(`/Good/status`);
};

// 获取商品性别字典
export const getGoodGender = () => {
  return http.get<Goods.ResGender[]>(`/Good/gender`);
};

// 获取商品部门列表
export const getGoodDepartment = () => {
  return http.get<Goods.ResDepartment[]>(`/Good/department`, {}, { cancel: false });
};

// 获取商品角色字典
export const getGoodRole = () => {
  return http.get<Goods.ResRole[]>(`/Good/role`);
};
